/**
 * @FileName: DemoController.java
 * @Package: top.swimmer.boot.controller
 * @author youshipeng
 * @created 2017/5/4 15:25
 * <p>
 * Copyright 2016 ziroom
 */
package top.swimmer.core.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import top.swimmer.core.annotation.ApplicationController;
import top.swimmer.core.model.Account;
import top.swimmer.core.model.options.AccountSearchOptions;
import top.swimmer.core.model.result.Results;
import top.swimmer.core.service.AccountService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p></p>
 *
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author youshipeng
 * @since 1.0
 * @version 1.0
 */
@ApplicationController
@RequestMapping("/demo")
public class DemoController extends BaseController {

    Logger LOGGER = LoggerFactory.getLogger(DemoController.class);

    @Resource(name = "accountService")
    private AccountService accountService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String searchPage(HttpServletResponse response) throws Exception {
        Account account = new Account();
        account.setUsername("you");
        account.setMobile("18566959956");
        accountService.create(account);
        return "search";
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Account get(HttpServletResponse response, @PathVariable Integer id) throws Exception {
        AccountSearchOptions options = new AccountSearchOptions();
        options.setMobile("18566959956");
        options.setCount(2);
        options.setStart(2);
        Results<Account> accountResult = accountService.search(options);
        return accountService.get(id);
    }
}